#include <iostream>
using namespace std;
#include <malloc.h>

class Person
{
public:
    Person(const string &name)
        : m_strName(name)
    {}
    Person()
        : m_strName("Unknow")
    {}

    static void* operator new(std::size_t size) throw (std::bad_alloc)
    {
        cout << "Person::new " << size << endl;
        return buff;
    }

    void Print()
    {
        cout << "Name: " << m_strName << endl;
    }

private:
    string m_strName;

    static char buff[50];
};

class Foo
{
public:
    static void* operator new(std::size_t size) throw (std::bad_alloc)
    {
        cout << "Foo::new " << size << endl;
        return buff;
    }
private:
    static char buff[50];
};

char Person::buff[50] = {0};

int main()
{
    cout << "--- Start ---" << endl;
    Person *pp = new Person;
    pp->Print();
    new Foo;
    cout << "--- End ---" << endl;
    return 0;
}
